/*****************************************************************
 *@Copyright all rights reserved ? 2014 Yuga
 *@author Oplink OMS
 *Contact: zengkang007@gmail.com
 *****************************************************************/
package com.oplink.webems.modules.sys.entity;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import com.oplink.webems.common.persistence.DataEntity;
import com.oplink.webems.modules.sys.dto.ITreeDTO;

/**
 * 表单配置Entity
 * 
 * @author Oplink OMS
 * @version 2014-09-03
 */
@Entity
@Table(name = "sys_config")
@DynamicInsert
@DynamicUpdate
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Config extends DataEntity implements ITreeDTO {

	private static final long serialVersionUID = 1L;
	private String parentId;// 父级节点
	private String parentIds; // 层次结构点，用作排序
	private String parentName; // 层次结构点，用作排序
	private User user;
	private String catalog; // 所属目录、分类
	private String label; // 显示标签
	private String value; // 值
	private String isEnable; // 是否可用
	private String readOnly;// 是否只读
	private Integer sort; // 排序
	private String field; // 字段类型
	private String fieldType; // 字段类型
	private String defaultValue; // 是否禁用菜单
	private String formatStr; // 单位格式
	private String mappingEnt; // 映射实体
	private String childFormList;// 子表单名称列表
	private String formLabel;// 作为子表单的名称
	private String ext_1; // 扩展字段1
	private String ext_2; // 扩展字段2

	public String getReadOnly() {
		return readOnly;
	}

	public void setReadOnly(String readOnly) {
		this.readOnly = readOnly;
	}

	public String getParentName() {
		return parentName;
	}

	public void setParentName(String parentName) {
		this.parentName = parentName;
	}

	@Override
	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	@Override
	public String getParentIds() {
		return parentIds;
	}

	public void setParentIds(String parentIds) {
		this.parentIds = parentIds;
	}

	public String getFormLabel() {
		return formLabel;
	}

	public void setFormLabel(String formLabel) {
		this.formLabel = formLabel;
	}

	public String getCatalog() {
		return catalog;
	}

	public void setCatalog(String catalog) {
		this.catalog = catalog;
	}

	@Override
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getIsEnable() {
		return isEnable;
	}

	public void setIsEnable(String isEnable) {
		this.isEnable = isEnable;
	}

	public String getChildFormList() {
		return childFormList;
	}

	public void setChildFormList(String childFormList) {
		this.childFormList = childFormList;
	}

	@Override
	public String getFieldType() {
		return fieldType;
	}

	public void setFieldType(String fieldType) {
		this.fieldType = fieldType;
	}

	public String getField() {
		return field;
	}

	public void setField(String field) {
		this.field = field;
	}

	public String getDefaultValue() {
		return defaultValue;
	}

	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	public String getFormatStr() {
		return formatStr;
	}

	public void setFormatStr(String formatStr) {
		this.formatStr = formatStr;
	}

	public String getMappingEnt() {
		return mappingEnt;
	}

	public void setMappingEnt(String mappingEnt) {
		this.mappingEnt = mappingEnt;
	}

	public String getExt_1() {
		return ext_1;
	}

	public void setExt_1(String ext_1) {
		this.ext_1 = ext_1;
	}

	public String getExt_2() {
		return ext_2;
	}

	public void setExt_2(String ext_2) {
		this.ext_2 = ext_2;
	}

	// JPA ����USER_ID�еĶ��һ��ϵ����
	@ManyToOne
	@JoinColumn(name = "user_id")
	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@NotNull
	public int getSort() {
		return sort;
	}

	public void setSort(int sort) {
		this.sort = sort;
	}

	// 转化成CfgValue实体
	public CfgValue toValue() {
		CfgValue cfgValue = new CfgValue();
		cfgValue.setCatalog(catalog);
		cfgValue.setField(field);
		cfgValue.setValue(value);
		return cfgValue;
	}
}
